<?php
/**
 * User: zhangligang
 * Email: tzhang2450@163.com
 * Date: 2018/11/26
 * Time: 14:09
 */

namespace App\Providers;

use PHPMailer\PHPMailer\PHPMailer;

class MailSmtp
{
    public static function send($email, $title = '', $content)
    {
        header("content-type:text/html;charset=utf-8");
        $mail = new PHPMailer();
        $mail->isSMTP();
        $mail->Host = "smtp.qq.com";
        $mail->SMTPAuth = true;
        $mail->Username = "279412324@qq.com";
        $mail->Password = "vxomxoqqsezqcbaj";
        $mail->From = "279412324@qq.com";
        $mail->FromName = "亿校云科技";
        $mail->CharSet = "utf-8";
        $mail->Encoding = "base64";
        $mail->addAddress($email,"toyou");
        $mail->addReplyTo("279412324@qq.com","wo");
        $mail->Port = 587;
        $mail->isHTML(true);
        $mail->Subject = $title;
        $mail->Body = $content;
        $mail->AltBody ="text/html";
        if(!$mail->send())
        {
            return ['body' => [], 'status' => 404, 'message' => "邮件错误信息: " . $mail->ErrorInfo];
        }
        return ['body' => [], 'status' => 200, 'message' => "邮件发送成功!"];
    }
}